package attr

import (
	"time"
)

const SettingAttrName = "setting_attr"

type SettingAttr struct {
	Id   int    `json:"id" orm:"auto" sql:"INT"`
	Name string `json:"name" sql:"VARCHAR"`

	Type byte `json:"type" sql:"TINYINT"`

	Power int `json:"power" sql:"INT"`

	Key     string `json:"key" sql:"VARCHAR"`
	StatKey string `json:"stat_key" sql:"VARCHAR"`

	Sort int `json:"sort" sql:"INT"`

	IsData   bool `json:"is_data" sql:"TINYINT"`
	IsBattle bool `json:"is_battle" sql:"TINYINT"`

	singleValue int

	UpdateTime *time.Time `json:"update_time" orm:"updateTime" sql:"DATETIME"`
}

func (attr *SettingAttr) ComputeValue() {
	if attr.Power > 0 {
		attr.singleValue = 8 / attr.Power
	} else {
		attr.singleValue = 0
	}
}
